﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using KPIS.GERP.GHRMS.BLL;
using KPIS.GERP.GHRMS.IBLL;
using Telerik.Web.UI;
using KPIS.Utils;
using System.Web.UI.HtmlControls;

namespace KPIS.GERP.GHRMS.APP.App_UI.Forms
{
    public partial class PR_InComeSurchargeAnother : System.Web.UI.Page
    {
        private SsMng ssMng = new SsMng();
        IPayrollsBLL payrollsExtraBLL = new PayrollsBLL();
        protected void Page_Load(object sender, EventArgs e)
        {
            IncludeJava();
            if (!IsPostBack)
            {
                Session["pay_seq"] = Request.QueryString["pay_seq"];
                Session["emp_seq"] = Request.QueryString["emp_seq"];
                LoadDataGrid();
            }            
        }
        public void IncludeJava()
        {
            HtmlGenericControl script = new HtmlGenericControl();
            script.TagName = "script";
            script.Attributes.Add("type", "text/javascript");
            script.Attributes.Add("src", "../../Scripts/jsfunction.js");
            Page.Header.Controls.Add(script);
        }

        private void LoadDataGrid()
        {
            try
            {
                //ListPayrollsExtra
                DataSet ds = payrollsExtraBLL.ListPayrollsExtra(Int32.Parse(Session["pay_seq"].ToString())
                                , Int32.Parse(Session["emp_seq"].ToString()));
                RadGrid2.DataSource = ds.Tables[0];
                RadGrid2.DataBind();
            }
            catch (Exception ex)
            {
                Web.ShowAlert(this,ex.Message);
            }
        }

        protected void RadGrid2_ItemCommand(object source, Telerik.Web.UI.GridCommandEventArgs e)
        {
            try
            {
                if (e.CommandName == "btnClick")
                    return;

                if (e.CommandName == "Delete")
                {
                    int seq = Convert.ToInt32((e.Item as GridDataItem).OwnerTableView.DataKeyValues[e.Item.ItemIndex]["pay_dtls_seq"]);
                    payrollsExtraBLL.DeletePayrollsExtra(seq, ssMng.EmpSeq);
                }
                LoadDataGrid();                
            }
            catch (Exception ex)
            {
                Web.ShowAlert(this, ex.Message);
            }

        }
    }
}
